package com.lancoo.cvas.controller;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
import com.lancoo.cvas.aspect.LogAnnotation;
import com.lancoo.cvas.entity.Course;
import com.lancoo.cvas.entity.Student;
import com.lancoo.cvas.entity.TeachingClass;
import com.lancoo.cvas.pojo.common.Deleted;
import com.lancoo.cvas.pojo.dto.SubTeachingClassRoomDto;
import com.lancoo.cvas.pojo.dto.UpdateOddEvenSubClassDto;
import com.lancoo.cvas.pojo.vo.*;
import com.lancoo.cvas.service.ParameterSettingService;
import com.lancoo.cvas.service.SubClassService;
import com.lancoo.cvas.service.TeachingClassService;
import com.lancoo.cvas.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.stream.Collectors;

@Api(tags = "拆班设置")
@RestController
@RequestMapping("/api/v5.0.1/web/subClass")
public class SubClassController {


    @Resource
    public SubClassService subClassService;
    @Resource
    public TeachingClassService teachingClassService;
    @Resource
    public ParameterSettingService parameterSettingService;


    @GetMapping("/getSubClassList")
    @ApiOperation("获取拆班记录")
    @LogAnnotation(operationType = "3", operationContent = "获取拆班记录")
    public Result<List<SubClassDto>> getSubClassList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                     @ApiParam(value = "拆班类型id传null为全部", required = false) @RequestParam(required = false) Integer flag,
                                                     @ApiParam(value = "年级id", required = true) @RequestParam String gradeId,
                                                     @ApiParam(value = "班级名称关键字", required = false) @RequestParam(required = false) String keyword) {
        return Result.ofSuccess(subClassService.getSubClassList(taskId, flag, gradeId, keyword));
    }


    @PostMapping("/deletedSubClass")
    @ApiOperation("删除拆班班级")
    @LogAnnotation(operationType = "4", operationContent = "删除拆班班级")
    public Result<String> deletedSubClass(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId
            , @ApiParam(value = "拆班班级对应的uuid", required = true) @RequestBody List<String> subIds) {
        return Result.ofSuccess(subClassService.deletedSubClass(taskId, subIds));
    }


    @GetMapping("/deletedSelectSubClass")
    @ApiOperation("删除选课课程的拆班班级")
    @LogAnnotation(operationType = "4", operationContent = "删除选课课程的拆班班级")
    public Result<String> deletedSelectSubClass(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId
            , @ApiParam(value = "拆班班级对应的uuid", required = true) @RequestParam Long courseId,
            @ApiParam(value = "拆班班级对应的uuid", required = true) @RequestParam String gradeId) {

       List<TeachingClass> teachingClassList = teachingClassService.lambdaQuery().eq(TeachingClass::getTaskId,taskId)
               .eq(TeachingClass::getGradeId,gradeId).eq(TeachingClass::getCourseId,courseId).eq(TeachingClass::getFlag,1)
               .eq(TeachingClass::getDeleted, Deleted.NOT.getCode())
               .isNotNull(TeachingClass::getUniqueShiftSign).list();

        List<String> collect = teachingClassList.stream().filter(p -> ObjUtil.isNotNull(p.getSubId()) && p.getSubId().equals(0)).map(TeachingClass::getUniqueShiftSign).distinct().collect(Collectors.toList());
        if(CollUtil.isNotEmpty(collect)){
            subClassService.deletedSubClass(taskId, collect);
        }

        return Result.ofSuccess("对应单双拆班已删除");


    }


    //单双号拆班
    @GetMapping("/getClassList")
    @ApiOperation("获得拆班班级")
    @LogAnnotation(operationType = "3", operationContent = "获得拆班班级")
    public Result<List<ClassInfoDto>> getClassList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId) {
        return Result.ofSuccess(subClassService.getClassList(taskId));
    }


    @GetMapping("/getSubCourse")
    @ApiOperation("获取拆班课程")
    @LogAnnotation(operationType = "3", operationContent = "获取拆班课程")
    public Result<List<SubCourseDto>> getSubCourse(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                   @ApiParam(value = "对应行政班id", required = true) @RequestParam Long classId) {
        return Result.ofSuccess(subClassService.getSubCourse(taskId, classId));
    }


    @PostMapping("/addOddEvenSubClass")
    @ApiOperation("添加单双号拆班")
    @LogAnnotation(operationType = "2", operationContent = "添加单双号拆班")
    public Result addOddEvenSubClass(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                     @ApiParam(value = "拆班id uuid", required = true) @RequestParam(required = false) String subId,
                                     @ApiParam(value = "拆班信息", required = true) @RequestBody SubInputDto data) {
        return subClassService.addOddEvenSubClass(taskId, subId, data.getData());
    }


    @GetMapping("/getOddEvenSubClass")
    @ApiOperation("获取单双号拆班列表")
    @LogAnnotation(operationType = "3", operationContent = "获取单双号拆班列表")
    public Result<AddOddEvenDto> getOddEvenSubClass(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                    @ApiParam(value = "拆班id uuid", required = true) @RequestParam(required = true) String subId) {
        return Result.ofSuccess(subClassService.getOddEvenSubClass(taskId, subId));
    }


    @PostMapping("/updateOddEvenSubClass")
    @ApiOperation("修改单双号拆班列表")
    @LogAnnotation(operationType = "2", operationContent = "修改单双号拆班列表")
    public Result<String> updateOddEvenSubClass(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                @ApiParam(value = "拆班id uuid", required = true) @RequestBody UpdateOddEvenSubClassDto updateOddEvenSubClassDto) {
        return Result.ofSuccess(subClassService.updateOddEvenSubClass(taskId, updateOddEvenSubClassDto.getSubId(), updateOddEvenSubClassDto.getTeachingClassIds(),
                updateOddEvenSubClassDto.getTeacherId(), updateOddEvenSubClassDto.getTeacherName(), updateOddEvenSubClassDto.getRoomId()));
    }


    @PostMapping("/deletedOddEvenSubClass")
    @ApiOperation("删除单双号拆班列表")
    @LogAnnotation(operationType = "4", operationContent = "删除单双号拆班列表")
    public Result deletedOddEvenSubClass(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                         @ApiParam(value = "拆班id uuid", required = true) @RequestParam(required = true) String subId,
                                         @ApiParam(value = "拆班id 删除对应的数据", required = true) @RequestBody List<DeletedOddEvenDto> data) {
        return subClassService.deletedOddEvenSubClass(taskId, subId, data);
    }


    //todo 常规拆班
    @GetMapping("/getRegularSubCourseList")
    @ApiOperation("获取常规拆班课程")
    @LogAnnotation(operationType = "3", operationContent = "获取常规拆班课程")
    public Result<List<Course>> getRegularSubCourseList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId) {
        return Result.ofSuccess(subClassService.getRegularSubCourseList(taskId));
    }


    @GetMapping("/getRegularSubClassList")
    @ApiOperation("获取常规拆班班级")
    @LogAnnotation(operationType = "3", operationContent = "获取常规拆班班级")
    public Result<List<SubGradeDto>> getRegularSubClassList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                            @ApiParam(value = "对应课程id", required = true) @RequestParam Long courseId) {
        return Result.ofSuccess(subClassService.getRegularSubClassList(taskId, courseId));
    }


    @GetMapping("/deletedRegularSubClassList")
    @ApiOperation("删除常规拆班班级")
    @LogAnnotation(operationType = "4", operationContent = "删除常规拆班班级")
    public Result<String> deletedRegularSubClassList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                     @ApiParam(value = "对应拆班id", required = true) @RequestParam String uuid,
                                                     @ApiParam(value = "对应删除教学班", required = true) @RequestParam Long teachingClassId,
                                                     @ApiParam(value = "对应课程id", required = true) @RequestParam Long courseId) {
        return Result.ofSuccess(subClassService.deletedRegularSubClassList(taskId, uuid, teachingClassId, courseId));
    }


    @PostMapping("/addRegularSubClass")
    @ApiOperation("添加常规拆班")
    @LogAnnotation(operationType = "2", operationContent = "添加常规拆班")
    public Result<String> addRegularSubClass(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                             @ApiParam(value = "拆班班级对应的uuid", required = true) @RequestParam(required = false) String uuid,
                                             @ApiParam(value = "拆班对应行政班id", required = true) @RequestBody AddRegularSubDto addRegularSubDto) {
        return Result.ofSuccess(subClassService.addRegularSubClass(taskId, uuid, addRegularSubDto));
    }


    @GetMapping("/getRegularSubClass")
    @ApiOperation("获取常规拆班信息")
    @LogAnnotation(operationType = "3", operationContent = "获取常规拆班信息")
    public Result<AddRegularDto> getRegularSubClass(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                    @ApiParam(value = "课程id", required = true) @RequestParam(required = false) Long courseId,
                                                    @ApiParam(value = "拆班班级对应的uuid", required = true) @RequestParam(required = false) String uuid) {
        return Result.ofSuccess(subClassService.getRegularSubClass(taskId, courseId, uuid));
    }


    @GetMapping("/updateRegularSubClass")
    @ApiOperation("修改常规拆班")
    @LogAnnotation(operationType = "2", operationContent = "修改常规拆班")
    public Result<String> updateRegularSubClass(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                @ApiParam(value = "拆班id uuid", required = true) @RequestParam(required = true) String subId,
                                                @ApiParam(value = "教学班id", required = true) @RequestParam(required = true) Long teachingClassId,
                                                @ApiParam(value = "教师id", required = true) @RequestParam(required = false) Long teacherId,
                                                @ApiParam(value = "教师名称", required = true) @RequestParam(required = false) String teacherName,
                                                @ApiParam(value = "场地类型", required = true) @RequestParam(required = false) Integer roomType) {
        return Result.ofSuccess(subClassService.updateRegularSubClass(taskId, subId, teachingClassId, teacherId, teacherName, roomType));
    }


    @GetMapping("/setTeachingClassRoom")
    @ApiOperation("直接对应教学班添加教室")
    @LogAnnotation(operationType = "2", operationContent = "编辑教学班教室")
    public Result<String> setTeachingClassRoom(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                               @ApiParam(value = "教室id", required = true) @RequestParam Integer roomType,
                                               @ApiParam(value = "教学班id", required = true) @RequestParam Long teachingClassId) {
        return Result.ofSuccess(subClassService.setTeachingClassRoom(taskId, roomType, teachingClassId));
    }

    @PostMapping("/setSubTeachingClassRoom")
    @ApiOperation("直接对应教学班添加教室")
    @LogAnnotation(operationType = "2", operationContent = "编辑拆班教学班教室")
    public Result<String> setSubTeachingClassRoom(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                  @ApiParam(value = "任务流程id", required = true) @RequestBody SubTeachingClassRoomDto subTeachingClassRoomDto) {
        return Result.ofSuccess(subClassService.setSubTeachingClassRoom(taskId, subTeachingClassRoomDto.getRoomId(), subTeachingClassRoomDto.getTeachingClassId()));
    }


    @GetMapping("/getStudentList")
    @ApiOperation("获取学生列表")
    @LogAnnotation(operationType = "3", operationContent = "获取学生列表")
    public Result<List<Student>> getStudentList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                @ApiParam(value = "教学班id", required = true) @RequestParam(required = true) Long teachingClassId,
                                                @ApiParam(value = "教学班id", required = true) @RequestParam(required = false) String keyword) {
        return Result.ofSuccess(subClassService.getStudentList(taskId, teachingClassId, keyword));
    }


    @PostMapping("/deletedRegularStudent")
    @ApiOperation("移除常规拆班学生")
    @LogAnnotation(operationType = "4", operationContent = "移除常规拆班学生")
    public Result<String> deletedRegularStudent(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                @ApiParam(value = "教学班id", required = true) @RequestParam(required = true) Long teachingClassId,
                                                @ApiParam(value = "教师id", required = true) @RequestBody(required = true) List<Long> studentIds) {
        return Result.ofSuccess(subClassService.deletedRegularStudent(taskId, teachingClassId, studentIds));
    }


    @GetMapping("/getRegularStudent")
    @ApiOperation("获取可以添加的学生列表")
    @LogAnnotation(operationType = "3", operationContent = "获取可以添加的学生列表")
    public Result<List<Student>> getRegularStudent(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                   @ApiParam(value = "拆班uuid", required = true) @RequestParam(required = true) String uuid) {
        return Result.ofSuccess(subClassService.getRegularStudent(taskId, uuid));
    }


    @PostMapping("/addRegularStudent")
    @ApiOperation("添加的学生列表")
    @LogAnnotation(operationType = "2", operationContent = "添加学生")
    public Result<String> addRegularStudent(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                            @ApiParam(value = "对应教学班id", required = true) @RequestParam(required = true) Long teachingClassId,
                                            @ApiParam(value = "对应教学班id", required = true) @RequestParam(required = true) String uuid,
                                            @ApiParam(value = "对应教学班id", required = true) @RequestBody(required = true) List<Long> studentDtos) {
        return Result.ofSuccess(subClassService.addRegularStudent(taskId, teachingClassId, studentDtos, uuid));
    }

    @GetMapping("/getOtherTeachingClassList")
    @ApiOperation("获取选课教学班列表")
    @LogAnnotation(operationType = "3", operationContent = "获取除选课的其他教学版列表")
    public Result<List<OtherTeachingClassList>> getOtherTeachingClassList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                          @ApiParam(value = "当前教学班id ", required = true) @RequestParam Long teachingClassId,
                                                                          @ApiParam(value = "拆班uuid", required = false) @RequestParam String uuid) {
        return Result.ofSuccess(subClassService.getOtherTeachingClassList(taskId, teachingClassId, uuid));
    }


    @PostMapping("/addToRegularStudent")
    @ApiOperation("学生添加到")
    @LogAnnotation(operationType = "2", operationContent = "将学生添加到对应的拆班教学班")
    public Result<String> addToRegularStudent(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                              @ApiParam(value = "来自教学班id", required = true) @RequestParam(required = true) Long fromTeachingClassId,
                                              @ApiParam(value = "去往教学班id", required = true) @RequestParam(required = true) Long toTeachingClassId,
                                              @ApiParam(value = "对应教学班id", required = true) @RequestBody(required = true) List<Long> studentDtos) {
        return Result.ofSuccess(subClassService.addToRegularStudent(taskId, fromTeachingClassId, toTeachingClassId, studentDtos));
    }


    //发布开课计划相关接口
    @GetMapping("/getTeachingClassTree")
    @ApiOperation("获得教学班对应树")
    @LogAnnotation(operationType = "3", operationContent = "获得教学班对应树")
    public Result<List<TeachingClassTree>> getTeachingClassTree(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                @ApiParam(value = "1、不需要排课状态 2、排课状态", required = true) @RequestParam Integer module) {
        return Result.ofSuccess(subClassService.getTeachingClassTree(taskId, module));
    }


    @GetMapping("/getClassInfoList")
    @ApiOperation("获取行政班列表")
    @LogAnnotation(operationType = "3", operationContent = "获取行政班列表")
    public Result<TeachingClassByClass> getClassInfoList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                         @ApiParam(value = "类型id 1 课程 2 环节 传null为全部 ", required = false) @RequestParam(required = false) Integer typeId,
                                                         @ApiParam(value = "对应的班级id 传null为全部 ", required = false) @RequestParam(required = false) Long classId,
                                                         @ApiParam(value = "对应年级id 传null 为全部", required = false) @RequestParam(required = false) String gradeId,
                                                         @ApiParam(value = "课程id 传null为全部", required = false) @RequestParam(required = false) Long courseId,
                                                         @ApiParam(value = "状态id 传null为全部", required = false) @RequestParam(required = false) Integer isEnable) {
        return Result.ofSuccess(subClassService.getClassInfoList(taskId, gradeId, typeId, courseId, classId, isEnable));
    }


    @GetMapping("/getClassInfoListV2")
    @ApiOperation("获取行政班列表")
    @LogAnnotation(operationType = "3", operationContent = "获取行政班列表")
    public Result<TeachingClassByClass> getClassInfoListV2(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                           @ApiParam(value = "类型id 1 课程 2 环节 传null为全部 ", required = false) @RequestParam(required = false) Integer typeId,
                                                           @ApiParam(value = "对应的班级id 传null为全部 ", required = false) @RequestParam(required = false) Long classId,
                                                           @ApiParam(value = "对应年级id 传null 为全部", required = false) @RequestParam(required = false) String gradeId,
                                                           @ApiParam(value = "页容", required = false) @RequestParam(required = false) Integer pageSize,
                                                           @ApiParam(value = "页", required = false) @RequestParam(required = false) Integer currentPage,
                                                           @ApiParam(value = "课程id 传null为全部", required = false) @RequestParam(required = false) Long courseId,
                                                           @ApiParam(value = "状态id 传null为全部", required = false) @RequestParam(required = false) Integer isEnable) {
        return Result.ofSuccess(subClassService.getClassInfoListV2(taskId, gradeId, typeId, courseId, classId, isEnable, pageSize, currentPage));
    }


    @GetMapping("/getSelectClassList")
    @ApiOperation("获取选课教学班列表")
    @LogAnnotation(operationType = "3", operationContent = "获取选课教学班列表")
    public Result<TeachingClassBySelect> getSelectClassList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                            @ApiParam(value = "对应的班级id ", required = false) @RequestParam(required = false) Long teachingClassId,
                                                            @ApiParam(value = "对应年级id ", required = true) @RequestParam(required = false) String gradeId,
                                                            @ApiParam(value = "页容", required = false) @RequestParam(required = false) Integer pageSize,
                                                            @ApiParam(value = "页", required = false) @RequestParam(required = false) Integer currentPage,
                                                            @ApiParam(value = "课程id 传null为全部", required = false) @RequestParam(required = false) Long courseId,
                                                            @ApiParam(value = "状态id 传null为全部", required = false) @RequestParam(required = false) Integer isEnable) {
        return Result.ofSuccess(subClassService.getSelectClassList(taskId, teachingClassId, gradeId, courseId, isEnable,pageSize,currentPage));
    }


    @GetMapping("/getSubClassInfoList")
    @ApiOperation("获取拆班教学班")
    @LogAnnotation(operationType = "3", operationContent = "获取拆班教学班")
    public Result<TeachingClassBySub> getSubClassInfoList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                          @ApiParam(value = "对应的班级id ", required = false) @RequestParam(required = false) Long teachingClassId,
                                                          @ApiParam(value = "拆班类型 ", required = true) @RequestParam(required = false) Integer subType,
                                                          @ApiParam(value = "对应年级id ", required = true) @RequestParam(required = false) String gradeId,
                                                          @ApiParam(value = "页容", required = false) @RequestParam(required = false) Integer pageSize,
                                                          @ApiParam(value = "页", required = false) @RequestParam(required = false) Integer currentPage,
                                                          @ApiParam(value = "课程id 传null为全部", required = false) @RequestParam(required = false) Long courseId,
                                                          @ApiParam(value = "状态id 传null为全部", required = false) @RequestParam(required = false) Integer isEnable) {
        return Result.ofSuccess(subClassService.getSubClassInfoList(taskId, teachingClassId, subType, gradeId, courseId, isEnable,pageSize,currentPage));
    }


    @GetMapping("/getMixedClassInfoList")
    @ApiOperation("获取合班列表")
    @LogAnnotation(operationType = "3", operationContent = "获取合班列表")
    public Result<TeachingClassByMerge> getMixedClassInfoList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                              @ApiParam(value = "对应的班级id ", required = true) @RequestParam(required = false) Long teachingClassId,
                                                              @ApiParam(value = "对应年级id ", required = true) @RequestParam(required = false) String gradeId,
                                                              @ApiParam(value = "课程id 传null为全部", required = false) @RequestParam(required = false) Long courseId,
                                                              @ApiParam(value = "状态id 传null为全部", required = false) @RequestParam(required = false) Integer isEnable) {
        return Result.ofSuccess(subClassService.getMixedClassInfoList(taskId, teachingClassId, gradeId, courseId, isEnable));
    }


    @PostMapping("/mergeTeachingClassList")
    @ApiOperation("合班")
    @LogAnnotation(operationType = "2", operationContent = "合班")
    public Result<String> mergeTeachingClassList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                 @ApiParam(value = "对应的教学班id ", required = true) @RequestBody MergeTeachingClassDto mergeTeachingClassDto) {
        return Result.ofSuccess(subClassService.MergeTeachingClassList(taskId, mergeTeachingClassDto));
    }

    @GetMapping("/getMergeTeachingClass")
    @ApiOperation("获取合并后的合班")
    @LogAnnotation(operationType = "3", operationContent = "获取合班后的教学班")
    public Result<TeachingClassMergeInfo> getMergeTeaching(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                           @ApiParam(value = "对应的教学班id ", required = true) @RequestParam(required = true) String uuid) {
        return Result.ofSuccess(subClassService.getMergeTeaching(taskId, uuid));
    }

    @PostMapping("/deleteMergeTeachingClass")
    @ApiOperation("删除合班")
    @LogAnnotation(operationType = "4", operationContent = "删除合班")
    public Result<String> deleteMergeTeachingClass(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                   @ApiParam(value = "需要删除的合班教学班id ", required = true) @RequestBody List<Long> mergeTeachingClass) {
        return Result.ofSuccess(subClassService.deleteMergeTeachingClass(taskId, mergeTeachingClass));
    }


    @PostMapping("/updateBatchTeaching")
    @ApiOperation("批量修改教师")
    @LogAnnotation(operationType = "2", operationContent = "批量修改教师")
    public Result<String> updateBatchTeaching(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                              @ApiParam(value = "修改教学班id ", required = true) @RequestBody UpdateTeacherBatchDto teachingClassIds) {
        return Result.ofSuccess(parameterSettingService.updateBatchTeaching(taskId, teachingClassIds.getTeachingClassId(), teachingClassIds.getTeacherIds(), teachingClassIds.getHourType()));
    }

    @PostMapping("/updateBatchAssessment")
    @ApiOperation("批量修改考核方式")
    @LogAnnotation(operationType = "2", operationContent = "批量修改考核方式")
    public Result<String> updateBatchAssessment(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                @ApiParam(value = "修改教学班id ", required = true) @RequestBody(required = true) UpdateBatchAssessment updateBatchAssessment) {
        return Result.ofSuccess(subClassService.updateBatchAssessment(taskId, updateBatchAssessment.getTeachingClassId(), updateBatchAssessment.getAssessmentId()));
    }


    @PostMapping("/updateBatchRoomType")
    @ApiOperation("批量设置场地类型")
    @LogAnnotation(operationType = "2", operationContent = "批量设置场地类型")
    public Result<String> updateBatchRoomType(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                              @ApiParam(value = "修改教学班id ", required = true) @RequestBody(required = true) UpdateBatchRoomType updateBatchRoomType) {
        return Result.ofSuccess(subClassService.updateBatchRoomType(taskId, updateBatchRoomType));
    }

    @PostMapping("/updateBatchRoom")
    @ApiOperation("批量设置教室")
    @LogAnnotation(operationType = "2", operationContent = "批量设置教室")
    public Result<String> updateBatchRoomId(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                            @ApiParam(value = "修改教学班id ", required = true) @RequestBody(required = true) UpdateBatchRoom updateBatchRoom) {
        return Result.ofSuccess(subClassService.updateBatchRoomId(taskId,updateBatchRoom));
    }


    @PostMapping("/UpdateBatchConnectSection")
    @ApiOperation("批量修改连上节次")
    @LogAnnotation(operationType = "2", operationContent = "批量修改连上节次")
    public Result<String> updateBatchConnectSection(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                    @ApiParam(value = "修改教学班id ", required = true) @RequestBody(required = false) UpdateBatchConnectSection updateBatchConnectSection) {
        return Result.ofSuccess(subClassService.updateBatchConnectSection(taskId, updateBatchConnectSection.getTeachingClassId(), updateBatchConnectSection.getConnectSection()));
    }


    @PostMapping("/updateBatchConnectNumber")
    @ApiOperation("批量修改连上次数")
    @LogAnnotation(operationType = "2", operationContent = "批量修改连上次数")
    public Result<String> updateBatchConnectNumber(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                   @ApiParam(value = "修改教学班id ", required = true) @RequestBody(required = false) UpdateBatchConnectNumber updateBatchConnectNumber) {
        return Result.ofSuccess(subClassService.updateBatchConnectNumber(taskId, updateBatchConnectNumber.getTeachingClassId(), updateBatchConnectNumber.getConnectNumber()));
    }


    @PostMapping("/updateBatchWeek")
    @ApiOperation("批量修改周次")
    @LogAnnotation(operationType = "2", operationContent = "批量修改周次")
    public Result updateBatchWeek(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                  @ApiParam(value = "修改教学班id ", required = true) @RequestBody(required = false) UpdateBatchWeekInput teachingClassIds) {
        return subClassService.updateBatchWeek(taskId, teachingClassIds);
    }


    @GetMapping("/updateWeek")
    @ApiOperation("修改周次")
    @LogAnnotation(operationType = "2", operationContent = "修改周次")
    public Result updateWeek(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                             @ApiParam(value = "修改教学班id ", required = true) @RequestParam(required = false) Long teachingClassId,
                             @ApiParam(value = "讲授类型", required = true) @RequestParam(required = false) Integer hourType,
                             @ApiParam(value = "1 课程 2 环节", required = true) @RequestParam(required = false) Integer flag,
                             @ApiParam(value = "0 未设置单双班 1 单班 2 双班", required = true) @RequestParam(required = false) Integer sign,
                             @ApiParam(value = "周数", required = true) @RequestParam(required = false) String week,
                             @ApiParam(value = "连上节次", required = true) @RequestParam(required = false) Integer connectSection,
                             @ApiParam(value = "连上次数", required = true) @RequestParam(required = false) Integer connectNumber,
                             @ApiParam(value = "开始周次", required = true) @RequestParam(required = false) Integer startWeek,
                             @ApiParam(value = "结束周次", required = true) @RequestParam(required = false) Integer endWeek,
                             @ApiParam(value = "总学时", required = true) @RequestParam(required = false) Integer totalHour) {
        return subClassService.updateWeek(taskId, teachingClassId, hourType, week, totalHour, flag, connectSection, connectNumber, sign, startWeek, endWeek);
    }


    @GetMapping("/updateConnectNumber")
    @ApiOperation("修改连上次数")
    @LogAnnotation(operationType = "2", operationContent = "修改连上次数")
    public Result<String> updateConnectNumber(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                              @ApiParam(value = "修改教学班id ", required = true) @RequestParam(required = false) Long teachingClassId,
                                              @ApiParam(value = "讲授类型", required = true) @RequestParam(required = false) Integer hourType,
                                              @ApiParam(value = "周数", required = true) @RequestParam(required = false) Integer connectNumber) {
        return Result.ofSuccess(subClassService.updateConnectNumber(taskId, teachingClassId, hourType, connectNumber));
    }


    @GetMapping("/checkSubClassIsEnbale")
    @ApiOperation("检查拆班是否设置成功")
    @LogAnnotation(operationType = "3", operationContent = "检查拆班参数是否设置成功")
    public Result<List<String>> checkSubClassIsEnbale(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId) {
        return Result.ofSuccess(subClassService.checkSubClassIsEnbale(taskId));
    }


    @GetMapping("/updateConnectSection")
    @ApiOperation("修改连上节次")
    @LogAnnotation(operationType = "2", operationContent = "修改连上节次")
    public Result<String> updateConnectSection(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                               @ApiParam(value = "修改教学班id ", required = true) @RequestParam(required = false) Long teachingClassId,
                                               @ApiParam(value = "讲授类型", required = true) @RequestParam(required = false) Integer hourType,
                                               @ApiParam(value = "周数", required = true) @RequestParam(required = false) Integer connectSection) {
        return Result.ofSuccess(subClassService.updateConnectSection(taskId, teachingClassId, hourType, connectSection));
    }


    @GetMapping("/updateIsEnable")
    @ApiOperation("修改是否启用")
    @LogAnnotation(operationType = "2", operationContent = "修改是否启用")
    public Result<String> updateIsEnable(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                         @ApiParam(value = "修改教学班id ", required = true) @RequestParam(required = false) Long teachingClassId,
                                         @ApiParam(value = "周数", required = true) @RequestParam(required = false) Integer isEnable) {
        return Result.ofSuccess(parameterSettingService.updateIsEnable(taskId, teachingClassId, isEnable));
    }


    @PostMapping("/whetherMixClass")
    @ApiOperation("是否可以合班")
    @LogAnnotation(operationType = "3", operationContent = "判断是否可以合班")
    public Result<Boolean> whetherMixClass(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                           @ApiParam(value = "合班教学班ids ", required = true) @RequestBody List<Long> teachingClassIds) {
        return Result.ofSuccess(subClassService.whetherMixClass(taskId, teachingClassIds));
    }


    @PostMapping("/getTeachingClassListByTeachingClassIds")
    @ApiOperation("是否可以合班")
    @LogAnnotation(operationType = "3", operationContent = "获取教学班列表")
    public Result<List<CourseInformation>> getTeachingClassList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                @ApiParam(value = "合班教学班ids ", required = true) @RequestBody List<Long> teachingClassIds) {
        return Result.ofSuccess(subClassService.getTeachingClassList(taskId, teachingClassIds));
    }



    @GetMapping("/classToExcel")
    @ApiOperation("导出行政班信息")
    @LogAnnotation(operationType = "14", operationContent = "导出行政班信息")
    public void classToExcel(@ApiParam(value = "返回响应", required = false) HttpServletResponse response,
                             @ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                             @ApiParam(value = "类型id 1 课程 2 环节 传null为全部 ", required = false) @RequestParam(required = false) Integer typeId,
                             @ApiParam(value = "类型名称", required = false) @RequestParam(required = false) String typeName,
                             @ApiParam(value = "对应的班级id 传null为全部 ", required = false) @RequestParam(required = false) Long classId,
                             @ApiParam(value = "对应的班级名称 ", required = false) @RequestParam(required = false) String className,
                             @ApiParam(value = "对应年级id 传null 为全部", required = false) @RequestParam(required = false) String gradeId,
                             @ApiParam(value = "对应年级名称", required = false) @RequestParam(required = false) String gradeName,
                             @ApiParam(value = "课程id 传null为全部", required = false) @RequestParam(required = false) Long courseId,
                             @ApiParam(value = "对应课程名称", required = false) @RequestParam(required = false) String courseName,
                             @ApiParam(value = "状态id 传null为全部", required = false) @RequestParam(required = false) Integer isEnable) {
        subClassService.classToExcel(response, taskId, typeId, typeName, classId, className, gradeId, gradeName, courseId, courseName, isEnable);
    }


    @GetMapping("/selectClassToExcel")
    @ApiOperation("导出教学班")
    @LogAnnotation(operationType = "14", operationContent = "导出选课教学班信息")
    public void selectClassToExcel(@ApiParam(value = "返回响应", required = false) HttpServletResponse response,
                                   @ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                   @ApiParam(value = "对应的班级id ", required = true) @RequestParam(required = false) Long teachingClassId,
                                   @ApiParam(value = "对应教学班名称 ", required = true) @RequestParam(required = false) String teachingClassName,
                                   @ApiParam(value = "对应年级id ", required = true) @RequestParam(required = false) String gradeId,
                                   @ApiParam(value = "对应年级名称 ", required = true) @RequestParam(required = false) String gradeName,
                                   @ApiParam(value = "课程id 传null为全部", required = false) @RequestParam(required = false) Long courseId,
                                   @ApiParam(value = "对应课程名称", required = false) @RequestParam(required = false) String courseName,
                                   @ApiParam(value = "状态id 传null为全部", required = false) @RequestParam(required = false) Integer isEnable) {
        subClassService.selectClassToExcel(response, taskId, teachingClassId, teachingClassName, gradeId, gradeName, courseId, courseName, isEnable);
    }


    @GetMapping("/subClassToExcel")
    @ApiOperation("导出拆班")
    @LogAnnotation(operationType = "14", operationContent = "导出拆班教学班信息")
    public void subClassToExcel(@ApiParam(value = "返回响应", required = false) HttpServletResponse response,
                                @ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                @ApiParam(value = "对应的班级id ", required = false) @RequestParam(required = false) Long teachingClassId,
                                @ApiParam(value = "对应教学班名称 ", required = false) @RequestParam(required = false) String teachingClassName,
                                @ApiParam(value = "拆班类型 ", required = true) @RequestParam(required = false) Integer subType,
                                @ApiParam(value = "对应拆班类型 ", required = true) @RequestParam(required = false) String subTypeName,
                                @ApiParam(value = "对应年级id ", required = true) @RequestParam(required = false) String gradeId,
                                @ApiParam(value = "对应年级 ", required = true) @RequestParam(required = false) String gradeName,
                                @ApiParam(value = "课程id 传null为全部", required = false) @RequestParam(required = false) Long courseId,
                                @ApiParam(value = "对应课程名称", required = false) @RequestParam(required = false) String courseName,
                                @ApiParam(value = "状态id 传null为全部", required = false) @RequestParam(required = false) Integer isEnable) {
        subClassService.subClassToExcel(response, taskId, teachingClassId, teachingClassName, subType, subTypeName, gradeId, gradeName, courseId, courseName, isEnable);
    }


    @GetMapping("/mixClassToExcel")
    @ApiOperation("导出合班")
    @LogAnnotation(operationType = "14", operationContent = "导出合班教学班信息")
    public void mixClassToExcel(@ApiParam(value = "返回响应", required = false) HttpServletResponse response,
                                @ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                @ApiParam(value = "对应的班级id ", required = true) @RequestParam(required = false) Long teachingClassId,
                                @ApiParam(value = "对应教学班名称 ", required = true) @RequestParam(required = false) String teachingClassName,
                                @ApiParam(value = "对应年级id ", required = true) @RequestParam(required = false) String gradeId,
                                @ApiParam(value = "年级名称", required = true) @RequestParam(required = false) String gradeName,
                                @ApiParam(value = "课程id 传null为全部", required = false) @RequestParam(required = false) Long courseId,
                                @ApiParam(value = "课程名称", required = false) @RequestParam(required = false) String courseName,
                                @ApiParam(value = "状态id 传null为全部", required = false) @RequestParam(required = false) Integer isEnable) {
        subClassService.mixClassToExcel(response, taskId, teachingClassId, teachingClassName, gradeId, gradeName, courseId, courseName, isEnable);
    }


    @PostMapping("/bulk/excelToSubClass")
    @ApiOperation("拆班导入")
    @LogAnnotation(operationType = "13", operationContent = "拆班教学班导入")
    public void excelToSubClass(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                @ApiParam(value = "任务流程id", required = true) HttpServletResponse response,
                                @ApiParam(value = "符号 1 追加导入 2 覆盖",required = true)@RequestParam Integer flag,
                                @ApiParam("file") @RequestPart("file") MultipartFile file) {
        subClassService.excelToSubClass(taskId, file, response,flag);
    }


}
